using System;
using System.Collections.Generic;
using System.Text;

namespace Sedodream.Sudoku.Evaluators
{
	public class ScoreComparer : IComparer<IScore>
	{
		#region IComparer<IScore> Members

		public int Compare(IScore x, IScore y)
		{
			if (x == null)
				throw new ArgumentNullException("x");
			if (y == null)
				throw new ArgumentNullException("y");
			
			if (x.MajorScore == y.MajorScore &&
				x.MinorScore == y.MinorScore)
				return 0;

			if (x.MajorScore == y.MajorScore)
			{
				if (x.MinorScore == y.MinorScore)
					return 0;
				if (x.MinorScore < y.MinorScore)
					return 1;
				else
					return -1;
			}

			if (x.MajorScore < y.MajorScore)
				return 1;
			else
				return -1;
		}
		#endregion
	}
}
